package com.knowledgegraph.zhongyao.service.impl;

import java.util.List;
import java.util.UUID;

import com.knowledgegraph.common.utils.DateUtils;
import com.knowledgegraph.neo4j.domain.GraphNode;
import com.knowledgegraph.neo4j.mapper.GraphNodeMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.knowledgegraph.zhongyao.mapper.MedicineMapper;
import com.knowledgegraph.zhongyao.domain.Medicine;
import com.knowledgegraph.zhongyao.service.IMedicineService;
import org.springframework.transaction.annotation.Transactional;

/**
 * 药材维护Service业务层处理
 * 
 * @author ruoyi
 * @date 2023-07-03
 */
@Service
public class MedicineServiceImpl implements IMedicineService 
{
    @Autowired
    private MedicineMapper medicineMapper;
    @Autowired
    private GraphNodeMapper graphNodeMapper;
    /**
     * 查询药材维护
     * 
     * @param medicineKey 药材维护主键
     * @return 药材维护
     */
    @Override
    public Medicine selectMedicineByMedicineKey(String medicineKey)
    {
        return medicineMapper.selectMedicineByMedicineKey(medicineKey);
    }

    /**
     * 查询药材维护列表
     * 
     * @param medicine 药材维护
     * @return 药材维护
     */
    @Override
    public List<Medicine> selectMedicineList(Medicine medicine)
    {
        return medicineMapper.selectMedicineList(medicine);
    }

    /**
     * 新增药材维护
     * 
     * @param medicine 药材维护
     * @return 结果
     */
    @Override
    @Transactional
    public int insertMedicine(Medicine medicine, GraphNode graphNode)
    {
        graphNodeMapper.insertGraphNode(graphNode);
        medicine.setCreateTime(DateUtils.getNowDate());
        return medicineMapper.insertMedicine(medicine);
    }

    /**
     * 修改药材维护
     * 
     * @param medicine 药材维护
     * @return 结果
     */
    @Override
    @Transactional
    public int updateMedicine(Medicine medicine,GraphNode graphNode)
    {
        graphNodeMapper.updateGraphNode(graphNode);
        medicine.setUpdateTime(DateUtils.getNowDate());
        return medicineMapper.updateMedicine(medicine);
    }

    /**
     * 批量删除药材维护
     * 
     * @param medicineKeys 需要删除的药材维护主键
     * @return 结果
     */
    @Override
    public int deleteMedicineByMedicineKeys(String[] medicineKeys)
    {
        return medicineMapper.deleteMedicineByMedicineKeys(medicineKeys);
    }

    /**
     * 删除药材维护信息
     * 
     * @param medicineKey 药材维护主键
     * @return 结果
     */
    @Override
    public int deleteMedicineByMedicineKey(String medicineKey)
    {
        return medicineMapper.deleteMedicineByMedicineKey(medicineKey);
    }
}
